<script>
	import userLogin from "@/api/userLogin.js"
	import {
		commonLogin
	} from '@/api/login.js'
	export default {
		onLaunch: function() {
			// console.log('App Launch')
			// if(uni.getStorageSync('user') && uni.getStorageSync('user').phone){
			// 	userLogin().then(res=>{
			// 		console.log(res)
			// 		if(res.data.code == 200 ){
			// 			let data = JSON.parse(res.data.data);
			// 			console.log(data)
			// 			uni.setStorageSync('session_key', data.session_key);	
			// 			uni.setStorageSync('openid', data.openid);
			// 			commonLogin('phone',{phone: res.data.data,openid: openid}).then(res=>{
			// 				console.log('手机号登录',res)
			// 				if(res.data.code == 200){
			// 					if(res.data.data.phone){
			// 						//已完善信息
			// 						uni.setStorageSync("user",res.data.data)
			// 						uni.switchTab({
			// 							url:'/pages/tabBar/home/home'
			// 						})
			// 					}
			// 				}
			// 			})
			// 		}
			// 	})
			// }else{
			// 	this.jumpTo("/pages/tabBar/login/login")
			// }

			// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
			this.globalData.menu = uni.getMenuButtonBoundingClientRect();
			// #endif
			this.getWindowInfo()
			console.log('调试版本：v1.0.4')
		},
		onShow: function(e) {
			console.log('App Show', e)
		},
		onHide: function() {
			console.log('App Hide')
		},
		globalData: {
			version: '1.0.0',
			systemInfo: {},
			menu: {},
			statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
			imgUrl: 'https://zf.jxqyl.xyz/prod-api/profile/zufang',
			navigationBarHeight: '',
			navHeight: '',
		},
		methods: {
			jumpTo(url) {
				console.log(url)
				uni.navigateTo({
					url: url
				})
			},
			/* 获取机型适配信息 */
			getWindowInfo() {
				const custom = uni.getMenuButtonBoundingClientRect()
				// 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
				this.globalData.navigationBarHeight = custom.height + (custom.top - this.globalData.statusBarHeight) * 2
				// 总体高度 = 状态栏高度 + 导航栏高度
				this.globalData.navHeight = this.globalData.navigationBarHeight + this.globalData.statusBarHeight
			},
		}
	}

	const updateManager = uni.getUpdateManager();

	updateManager.onCheckForUpdate(function(res) {
		// 请求完新版本信息的回调
		console.log(res.hasUpdate);
	});

	updateManager.onUpdateReady(function(res) {
		uni.showModal({
			title: '更新提示',
			content: '新版本已经准备好，是否重启应用？',
			success(res) {
				if (res.confirm) {
					uni.clearStorage();
					// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
					updateManager.applyUpdate();
				}
			}
		});

	});

	updateManager.onUpdateFailed(function(res) {
		// 新的版本下载失败
		console.error('更新失败', res)
	});
</script>

<style lang="scss">
	@import "./static/iconfont/iconfont.css";
	/*每个页面公共css */
	@import "uview-ui/index.scss";
	@import "common/page.css";

	page {
		font-family: "微软雅黑";
	}

	.app-container {
		padding: 20rpx;
	}

	// 订单状态
	.status_0 {
		color: #1B81FF !important;
	}

	.status_1 {
		color: #10C595 !important;
	}

	.status_2 {
		color: #333333 !important;
	}

	.status_3 {
		color: #F00 !important;
	}

	.status_5 {
		color: #999999 !important;
	}

	// 设备状态
	.device_status_3 {
		color: #8e8e8e !important;
	}

	.device_status_1 {
		color: #9a16d2 !important;
	}

	.device_status_2 {
		color: red !important;
	}

	.device_status_0 {
		color: green !important;
	}

	.device_status_4 {
		color: blue !important;
	}

	// 设备问题状态
	.matter_status_0 {
		color: orange;
	}

	.matter_status_1 {
		color: blue;
	}

	.matter_status_2 {
		color: #00a0e9;
	}

	.matter_status_3 {
		color: red;
	}

	.matter_status_4 {
		color: green;
	}

	// 问题整改记录状态
	.reform_status_0 {
		color: blue;
	}

	.reform_status_1 {
		color: #00a0e9;
	}

	// 通用状态
	.common_status_0 {
		color: #FF0000;
	}

	.common_status_1 {
		color: green;
	}

	// 单行省略
	.line-clamp-1 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		white-space: normal;
		-webkit-box-orient: vertical;
	}

	// 超出两行省略
	.line-clamp-2 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		white-space: normal;
		-webkit-box-orient: vertical;
	}

	// 超出三行省略
	.line-clamp-3 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 3;
		white-space: normal;
		-webkit-box-orient: vertical;
	}

	// 校验*号
	.required::before {
		content: '*';
		display: inline-block;
		margin-left: -5rpx;
		color: #f00;
		padding: 0 5rpx;
	}
</style>